package com.xavier.lotterysystem.common.exception;

import com.xavier.lotterysystem.common.error.ErrorCode;
import lombok.Data;
import lombok.EqualsAndHashCode;

@EqualsAndHashCode(callSuper = true)
@Data
public class ControllerException extends RuntimeException{
    /**
     * 异常码
     * @see com.xavier.lotterysystem.common.error.ControllerErrorCodeConstants
     */
    private Integer code;
    /**
     * 异常信息
     */
    private String msg;

    //为了序列化
    public ControllerException(){

    }

    public ControllerException(Integer code, String msg){
        this.code = code;
        this.msg = msg;
    }

    public ControllerException(ErrorCode errorCode){
        this.code = errorCode.getCode();
        this.msg = errorCode.getMsg();
    }
}
